# Maintainer: Eric Bélanger <eric@archlinux.org>

pkgname=wavpack
pkgver=5.1.0
pkgrel=2
pkgdesc="Audio compression format with lossless, lossy and hybrid compression modes"
arch=('x86_64')
url="http://www.wavpack.com/"
license=('BSD')
depends=('glibc')
source=(http://www.wavpack.com/${pkgname}-${pkgver}.tar.bz2
        CVE-2018-6767.patch::"https://github.com/dbry/WavPack/commit/d5bf76b5.patch"
        CVE-2018-7253.patch::"https://github.com/dbry/WavPack/commit/36a24c78.patch"
        CVE-2018-7254.patch::"https://github.com/dbry/WavPack/commit/8e3fe45a.patch")
sha256sums=('1939627d5358d1da62bc6158d63f7ed12905552f3a799c799ee90296a7612944'
            'b5fad0bb3e9501709cb935f13eb5ff09a89168c06575b99d76c826e0462e201c'
            '2ab4589c16caddf7f9a1d99f10b3476505732355b98fdfca194e22172b08696c'
            '41a6c1ce80df806b3f96a7a2fa379372bb0ac91f55cb51b9e784574325a84347')

prepare() {
  cd $pkgname-$pkgver
# Fix security issues
  patch -p1 -i ../CVE-2018-6767.patch
  patch -p1 -i ../CVE-2018-7253.patch
  patch -p1 -i ../CVE-2018-7254.patch
}

build() {
  cd ${pkgname}-${pkgver}
  ./configure --prefix=/usr --disable-asm
  make
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install
  install -Dm644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
